package com.biz.primus.app.customercenter.controller;

import com.biz.primus.app.customercenter.feign.customercenter.CustomerCenterFeignClient;
import com.biz.primus.base.vo.PageResult;
import com.biz.primus.base.vo.commodity.ProductListItemVo;
import com.biz.primus.model.customercenter.vo.request.*;
import com.biz.primus.model.customercenter.vo.response.*;
import com.biz.primus.model.oms.vo.OmsHistoryOrderProductVo;
import com.biz.primus.model.oms.vo.OmsItemVo;
import com.biz.primus.model.oms.vo.OmsOrderRespVo;
import com.biz.primus.model.oms.vo.OmsOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制器基类,要求所有面向手机端的api都要继承此类
 *
 * @author jun.liu
 * @since 2017年11月15日
 * @usage
 *  。
 * @reviewer
 */
@RestController
@Slf4j
@RequestMapping("/customercenter/")
@Api(value = "用户收货地址模块接口文档")
@CrossOrigin(origins = "*", maxAge = 3600)
public class CustomerCenterBaseController
{

    private final CustomerCenterFeignClient customerCenterFeignClient;

    @Autowired
    public CustomerCenterBaseController(CustomerCenterFeignClient customerCenterFeignClient)
    {
        this.customerCenterFeignClient = customerCenterFeignClient;
    }

    /**
     * 根据手机号码判断是否是系统会员
     * @param vo
     */
    @ApiOperation(value = "根据手机号码判断是否是系统会员", response = SysMemberResponseVo.class, position = 1)
    @PostMapping("isSysMemberByMobile")
    public SysMemberResponseVo isSysMemberByMobile(@RequestBody IfSysMemberRequestVo vo)
    {
        return customerCenterFeignClient.isSysMemberByMobile(vo);
    }

    /**
     * 根据会员绑定手机号码获取会员信息
     * @param vo
     */
    @ApiOperation(value = "根据会员绑定手机号码获取会员信息", response = MemberInfoResponseVo.class, position = 2)
    @PostMapping("getMemberInfoByMobile")
    public MemberInfoResponseVo getMemberInfoByMobile(@RequestBody MemberInfoRequestVo vo)
    {
        return customerCenterFeignClient.getMemberInfoByMobile(vo);
    }

    /**
     * 根据手机号码注册为系统会员
     * @param vo
     */
    @ApiOperation(value = "根据手机号码注册为系统会员", response = RegistrMemberResponseVo.class, position = 3)
    @PostMapping("registerByMobile")
    public RegistrMemberResponseVo registerByMobile(@RequestBody IfRegMemberRequestVo vo)
    {
        return customerCenterFeignClient.registerByMobile(vo);
    }


    /**
     * 根据会员id查询会员地址列表 是否需要分页 分页增加分页参数
     * 按照新增地址时间倒序排列
     * @param vo
     * @return
     */
    @ApiOperation(value = "根据会员id查询会员地址列表", response = MemberAddressItemInfoResponseVo.class, responseContainer = "list", position = 4)
    @PostMapping("getMemberAddressItem")
    public List<MemberAddressItemInfoResponseVo> getMemberAddressItem(@RequestBody MemberAddressItemInfoPageRequestVo vo)
    {
        return customerCenterFeignClient.getMemberAddressItem(vo);
    }

    /**
     * 新增收货地址 考虑是否要设置默认
     * @param vo
     * @return
     */
    @ApiOperation(value = "新增收货地址", response = AddMemberAddressResponseVo.class, position = 5)
    @PostMapping("addMemberAddessInfo")
    public AddMemberAddressResponseVo addMemberAddessInfo(@RequestBody AddMemberAddressRequestVo vo)
    {
        return customerCenterFeignClient.addMemberAddessInfo(vo);
    }

    /**
     * 根据会员id获取针对会员推荐的商品
     * 按照下单购买时间倒序排列
     * @param vo
     * @return
     *
     */
    @ApiOperation(value = "根据会员id获取针对会员推荐的商品", response = RecommendProductResponseVo.class, responseContainer = "list", position = 6)
    @PostMapping("getMemberRecommendProductItem")
    public List<RecommendProductResponseVo> getMemberRecommendProductItem(@RequestBody RecommendProductItemInfoRequestVo vo)
    {
        return customerCenterFeignClient.getMemberRecommendProductItem(vo);
    }

    /**
     * 根据关键字模糊查询商品
     * @param vo
     * @return
     */
    @ApiOperation(value = "根据关键字模糊查询商品, 这是一个分页对象 还包含当前页面和总页，显示的是分页中的地下信息", response = ProductListItemVo.class, responseContainer = "list", position = 7)
    @PostMapping("findProductBykeyword")
    public PageResult<ProductListItemVo> findProductBykeyword(@RequestBody SearchKeywordProductRequestVo vo)
    {
        return customerCenterFeignClient.findProductBykeyword(vo);
    }

    /**
     * 根据商品信息查询相似的商品（和查询推荐商品一致 只是查询的枚举选择相似的）
     * @param vo
     * @return
     */
    @ApiOperation(value = "根据商品信息查询相似的商品（和查询推荐商品一致 只是查询的枚举选择相似的）", response = SimilarityProductResponseVo.class, responseContainer = "list", position = 8)
    @PostMapping("findSimilarityProductByProductInfo")
    public List<SimilarityProductResponseVo> findSimilarityProductByProductInfo(@RequestBody SearchSimilarityProductRequestVo vo)
    {
        return customerCenterFeignClient.findSimilarityProductByProductInfo(vo);
    }

    @ApiOperation(value = "查询会员购买过的订单商品, 这是一个分页对象 还包含当前页面和总页，显示的是分页中的地下信息", response = OmsHistoryOrderProductVo.class, responseContainer = "list", position = 9)
    @PostMapping("getMemberBuyProductItem")
    public PageResult<OmsHistoryOrderProductVo> getMemberBuyProductItem(@RequestBody BuyProductItemInfoPageRequestVo vo)
    {
        return customerCenterFeignClient.getMemberBuyProductItem(vo);
    }

    /**
     * 根据请求商品信息查询可用的促销活动
     * @param vo
     * @return
     */
    @PostMapping("getPromotionsInfoByProductInfo")
    @ApiOperation(value = "根据请求商品信息查询可用的促销活动", response = ProductPromotionsInfoResponseVo.class, responseContainer = "list", position = 10)
    public List<ProductPromotionsInfoResponseVo> getPromotionsInfoByProductInfo(@RequestBody BuyProductRequestVo vo)
    {
        return customerCenterFeignClient.getPromotionsInfoByProductInfo(vo);
    }

    /**
     * 根据会员信息获取会员所下的历史订单
     * 按照下单时间倒序排列
     * @param vo
     * @return
     */
    @PostMapping("getHistoryOrderByMemberInfo")
    @ApiOperation(value = "根据会员信息获取会员所下的历史订单 这是一个分页对象 还包含当前页面和总页，显示的是分页中的地下信息", response = OmsOrderVo.class, responseContainer = "list", position = 11)
    public PageResult<OmsOrderVo> getHistoryOrderByMemberInfo(@RequestBody HistoryOrderPageRequestVo vo)
    {
        return customerCenterFeignClient.getHistoryOrderByMemberInfo(vo);
    }

    /**
     * 根据订单编号订单详情获取
     * @param orderCode
     * @return
     */
    @GetMapping("getOrderDetail")
    @ApiOperation(value = "获取订单详情信息", response = OmsOrderRespVo.class, position = 12)
    public OmsOrderRespVo getOrderDetail(@ApiParam(value = "订单编码", required = true) @RequestParam("orderCode")
                                          String orderCode)
    {
        return customerCenterFeignClient.getOrderDetail(orderCode);
    }


}
